using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace WindowsApplication1
{

  
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        fopfiles try1;
        private void button1_Click(object sender, EventArgs e)
        {
            string str,Command;
            

            propertyGrid1.SelectedObject = try1;
         //   Command = "fop.bat -c conf\userconfig.xml -xml p\arabic\prohev.xml -xsl p\arabic\prohev.xsl -pdf prohev3.pdf";
            Command = "fop.bat -c conf\\userconfig.xml ";
            Command += " -xml " + try1.xml;//p\arabic\prohev.xsl -pdf prohev3.pdf";
            Command += " -xsl " + try1.xsl;
            Command += " -pdf " + try1.pdf;

            ExecuteCommand.ExecuteCmd cmd = new ExecuteCommand.ExecuteCmd(try1 .workingDirectory );
            cmd.ExecuteCommandSync(Command);

            str = cmd.result;
            MessageBox.Show(str);

            ExecuteCommand.ExecuteCmd cmdp = new ExecuteCommand.ExecuteCmd(try1.workingDirectory);
            cmdp.ExecuteCommandSync(try1.pdf);

            //str = cmd.result;
            //MessageBox.Show(str);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ExecuteCommand.ExecuteCmd cmdp = new ExecuteCommand.ExecuteCmd(try1 .workingDirectory );
            cmdp.ExecuteCommandSync(try1.pdf);
            //Form2 f = new Form2();
            //f.Show();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try1 = new fopfiles();

            try1.xml = "p\\arabic\\prohev.xml";
            try1.xsl = "p\\arabic\\prohev.xsl";
            try1.pdf = "prohev3.pdf";
            try1.workingDirectory = "D:\\xmlfo\\src\\ac";

            try
            {
                //Open the file written above and read values from it.
                Stream stream = File.Open("EmployeeInfo.osl", FileMode.Open);
                BinaryFormatter bformatter = new BinaryFormatter();

                //Reading
                try1 = (fopfiles)bformatter.Deserialize(stream);
                stream.Close();
                propertyGrid1.SelectedObject = try1;

            }
            catch { }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Stream stream = File.Open("EmployeeInfo.osl", FileMode.Create);
            BinaryFormatter bformatter = new BinaryFormatter();

            //Save
            bformatter.Serialize(stream, try1 );
            stream.Close();
        }
    }
    [Serializable()]   
    public class fopfiles
    {


        private string _xml, _xsl, _pdf,_workingDirectory;
        public string xml
        {
            get { return _xml; }
            set { _xml = value; }
        }
        public string xsl
        {
            get { return _xsl; }
            set { _xsl = value; }
        }
        public string pdf
        {
            get { return _pdf; }
            set { _pdf = value; }
        }
        public string workingDirectory
        {
            get { return _workingDirectory; }
            set { _workingDirectory = value; }
        }

    }

}